home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / cups / enable_browsing < prev    next >
Encoding:
Text File  |  2007-04-04  |  1.2 KB  |  60 lines

  1. #!/bin/sh -e
  2.  
  3. # Author: Martin Pitt <martin.pitt@ubuntu.com>
  4. # (C) 2005  Canonical Ltd.
  5. #
  6. # Configure CUPS IPP network browsing; this is only possible if "Browsing" is
  7. # present in cupsd.conf (i. e. browsing_status returns 0 or 1). If the setting
  8. # changed, CUPS will be restarted.
  9. #
  10. # Argument:
  11. # 0: disable browsing 
  12. # 1: enabled browsing
  13. # Return 0 on success, or 1 on failure (prints error to stderr)
  14.  
  15. CONF=/etc/cups/cupsd.conf
  16. STATUS_SCRIPT=/usr/share/cups/browsing_status
  17.  
  18. [ -x $STATUS_SCRIPT ] || {
  19.     echo "Error: cannot execute $STATUS_SCRIPT" >&2
  20.     exit 1
  21. }
  22.  
  23. set +e
  24. $STATUS_SCRIPT
  25. STATUS=$?
  26. set -e
  27.  
  28. case "$1" in
  29.     0)
  30.     NEWVAL=Off
  31.     ;;
  32.     1)
  33.     NEWVAL=On
  34.     ;;
  35.     *)
  36.     echo "Invalid argument (must be 0 or 1)" >&2
  37.     exit 1
  38.     ;;
  39. esac
  40.  
  41. [ $STATUS = 0 -o $STATUS = 1 ] || {
  42.     echo "Error: cannot modify custom configuration" >&2
  43.     exit 1
  44. }
  45.  
  46. # nothing to do?
  47. [ $1 != $STATUS ] || exit 0
  48.  
  49. sed -ri "s/^([[:space:]]*Browsing[[:space:]]+)(No|Off|Yes|On)([[:space:]]*(#.*)?)\$/\\1$NEWVAL\\3/i" $CONF
  50.  
  51. # restart CUPS
  52. # Automatically added by dh_installinit
  53. if [ -x "/etc/init.d/cupsys" ]; then
  54.     if [ -x /usr/sbin/invoke-rc.d ]; then
  55.     invoke-rc.d cupsys force-reload || exit 0
  56.     else
  57.     /etc/init.d/cupsys force-reload || exit 0
  58.     fi
  59. fi
  60.